<?php
$page->BodyId = 'smileys';
$page->Section = '';
$page->AddJsFile('smileys.page.js');

$page->SetWrapperFile('_wrapper');
$page->BodyClass .= $page->HideExtras?' hide_extras':'';
?>

<? $page->RenderCssFiles('carousel.css') ?>

<? if ( !$page->Smileys ): ?>
	<p>No smileys found</p>
<? else: ?>
	<div class="options">
		<ul>
			<li id="show_extras"><a href="<?=$page->ShowExtrasUrl?>">Show Extras</a></li>
			<li id="hide_extras"><a href="<?=$page->HideExtrasUrl?>">Hide Extras</a></li>
		</ul>
	</div>

	<div class="smileys">
		<? foreach ( $page->Smileys->Values as $smiley ): ?>
			<div class="smiley <?=$smiley->IsFavorite()?>">
				<h3>
					<a href="<?=$smiley->Href()?>"><img src="<?=$smiley->Url()?>" width="<?=$smiley->Width()?>" height="<?=$smiley->Height()?>" /></a>
				</h3>
				<div class="extras">
					<h3>
						<img src="<?=$smiley->Url()?>" width="<?=$smiley->Width()?>" height="<?=$smiley->Height()?>" />
					</h3>
					<? if ( $smiley->Title() ): ?>
						<h4><?=$smiley->Title()?></h4>
					<? endif ?>
					<p class="more_info">
						<a href="<?=$smiley->Href()?>">More info...</a>
					</p>
					<div class="code" title="Click to hilight and copy">
						<p class="html">
							<input type="text" value="<?=htmlentities('<img src="' . $smiley->Url() . '" />')?>" />
							<? /*<a href="<?=$page->SetCodeBbUrl?>">(ubb)</a>*/ ?>
						</p>
						<p class="ubb">
							<input type="text" value="[img]<?=$smiley->Url()?>[/img]" />
							<? /*<a href="<?=$page->SetCodeHtmlUrl?>">(html)</a>*/ ?>
						</p>
					</div>
					<? if ( $page->ArchiveType != 'user' && $page->ArchiveDisplay != 'user' && $smiley->User() && $smiley->User()->Dname() && $smiley->User()->Url() ) { ?>
						<p class="user">
							By: <a href="<?=$smiley->User()->Url?>"><?=$smiley->User()->Dname()?></a>
						</p>
					<? } ?>

					<? if ( $smiley->Tags() ): ?>
						<div class="tags">
							<h4>Tags:</h4>
							<ul>
								<? foreach ( $smiley->Tags()->Values as $key => $tag ): ?> 
									<li class="tag <?=($key < 3)?'top_tag':''?>">
										<? if ( $tag->UpUrl() ): ?>
											<span class="vote <?=$tag->Voted()?'voted':''?>">
												<a href="<?=$tag->UpUrl()?>" class="add_vote" title="Agree with this tagging">+</a>
												<a href="<?=$tag->DownUrl()?>" class="remove_vote" title="Remove your vote">-</a>
											</span>
										<? endif ?>
										<a href="<?=$tag->Url()?>"><?=$tag->Name()?> <span class="count">(<?=$tag->Count()?>)</span></a>
									</li>
								<? endforeach ?>
							</ul>
							<? if ( count($smiley->Tags()) > 3 ): ?>
								<p class="more"><a href="<?=$smiley->Href()?>">More tags...</a></p>
							<? endif ?>
						</div>
					<? endif ?>
					<div class="favorites">
						<ul>
							<li class="add_favorite"><a href="<?=$smiley->AddFavoriteUrl()?>">Add To Favorites</a></li>
							<li class="remove_favorite"><a href="<?=$smiley->RemoveFavoriteUrl()?>">Remove From Favorites</a></li>
						</ul>
					</div>
				</div>
			</div>
		<? endforeach ?>
	</div>
	<div id="pagination_wrapper">
		<? Site::RenderView('modules/_pagination', array('page' => $page->Pagination)) ?>
		<div class="clear"></div>
	</div>
<? endif ?>
